﻿@*@{
    Layout = null;
    var plugName = @news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name;
    var tableName = PageViewModel.PageTableID(this, plugName);
    var tableToolBar = PageViewModel.PageTableToolbar(this, plugName);
    var tableToolBarSearch = PageViewModel.PageTableToolbarSearch(this);
    var tableToolBarReset = PageViewModel.PageTableToolbarReset(this);

    var auditFunName = PageViewModel.PageFunctionName(this, "audit_mediasource", plugName);
    var auditDlgName = PageViewModel.PageEditDialog(this, "audit", plugName);
    var doAuditFunName = PageViewModel.PageEditDialog(this, "do_audit_fun", plugName);
    var auditUserIDFmtFun = PageViewModel.PageFunctionName(this, "AuditUserID_fmt", plugName);
    var auditLogoFmtFun = PageViewModel.PageFunctionName(this, "logo_fmt", plugName);
}
<div style="height:100%">
    <script type="text/javascript">
        function @auditFunName (id) {
            var dlg = $dlg('@auditDlgName');
            dlg.dialog({
                title: '来源审核', width: 800, height: 550,
                closed: false, cache: false, modal: true, maximizable: false, resizable: true,
                href: '~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/MediaSource/_AuditMediaSourceDlg/' + id,
                onResize: function () {
                    $(this).dialog('center');
                },
                buttons: [
                    {
                        text: "审核通过",
                        handler: function () {
                            @doAuditFunName (true, '通过');
                        },
                        iconCls: "icon-save"
                    }, {
                        text: "不通过",
                        handler: function () {
                            @doAuditFunName (false, '不通过');
                        },
                        iconCls: "icon-cancel"
                    }
                ],
                onClose: function () {
                    $('#@tableName').datagrid('reload');
                }
            });
        }

        function @doAuditFunName (result, resultMsg) {
            var form = $("#@auditDlgName").find("form");
            if (form.form('enableValidation').form('validate')) {
                $.messager.confirm(resultMsg, '确认' + resultMsg+'审核?', function (r) {
                    if (r) {
                        var item = form.form_to_json();
                        item.Result = result;
                        $.ajax({
                            url: "~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/MediaSource/DoMediaSourceAudit",
                            type: "POST",
                            data: item,
                            success: function (e) {
                                $('#@auditDlgName').dialog('close');
                                $('#@tableName').datagrid('reload');
                            },
                            error: function (e) {
                                ShowAjaxError(e);
                            }
                        });
                    }
                });
            }
        }
    </script>
    <script type="text/javascript">
        function @auditUserIDFmtFun (v, r, i) {
            var v = GetObject(v, '~/Systems/GetUserByID');
            if (v != null&&v.User!=null) { return v.User.FullName; }
        }

        function @auditLogoFmtFun (v, r, i) {
            return $.ImageFormat("@Admin.CYT369.Com.Utility.SystemSettingService.Instance.NewsBucket.HttpURL/" + v,r,i, "width:40px;height:40px;border-radius:5px");
        }
    </script>
    <script type="text/javascript">
        function @tableToolBarSearch {
            $('#@tableName').datagrid('load', {
                Name: $("#@tableToolBar").find("#_Name").textbox("getValue"),
                AuditStatus: $("#@tableToolBar").find("#_AuditStatusID").combobox("getValue"),
            });
        }

        function @tableToolBarReset {
            $("#@tableToolBar").find("#_Name").textbox("setValue", "");
            $("#@tableToolBar").find("#_AuditStatusID").combobox("setValue", "");
            @tableToolBarSearch ();
        }
    </script>


    <table id="@tableName" class="easyui-datagrid" style="width:100%;" rownumbers="true" fit="true"
           pagination="true" pageSize="20" pageList="@SystemSettingService.Instance.PageList"
           data-options="striped:true,border:false,singleSelect:true,url:'~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/MediaSource/GetMediaSources',method:'get',toolbar:'#@tableToolBar'">
        <thead>
            <tr>
                <th data-options="field:'_audit',align:'center',formatter:function(v,r,i){
                    if(r.AuditStatusID==0){
                    return GridRowAuditFmt('@auditFunName', r.Id);
                    }else{
                    return GridRowEditFmt('@auditFunName', r.Id);
                    }
                }" width="45">审核</th>
                <th data-options="field:'Name'" width="160">名称</th>
                <th data-options="field:'Description'" width="200">说明</th>
                <th data-options="field:'Logo',align:'center',formatter:@auditLogoFmtFun" width="120">Logo</th>
                <th data-options="field:'URL'" width="200">链接</th>
                <th data-options="field:'UserID'" width="140">所属用户</th>
                <th data-options="field:'ChangedTime',align:'center',formatter:$.DateTimeFmt" width="150">修改时间</th>
                <th data-options="field:'AuditStatusID',align:'center',formatter:$.CheckdFormat" width="100">审核状态</th>
                <th data-options="field:'AuditUserID',formatter:@auditUserIDFmtFun" width="150">审核人</th>
                <th data-options="field:'AuditRemark'" width="200">审核意见</th>
                <th data-options="field:'AuditTime',align:'center',formatter:$.DateTimeFmt" width="150">审核时间</th>
            </tr>
        </thead>
    </table>
    <div id="@tableToolBar" class="table-toolbar">
        <ul class="query-body">
            <li>
                <span>名称：</span>
                <input id="_Name" class="easyui-textbox" />
            </li>
            <li>
                <span>状态：</span>
                <select id="_AuditStatusID" class="easyui-combobox" data-options="editable:false" style="width:100px">
                    <option value="">所有</option>
                    <option value="1">已通过</option>
                    <option value="0">未通过</option>
                </select>
            </li>
            <li>
                <a href="javascript:@tableToolBarSearch" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
                <a href="javascript:@tableToolBarReset" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">重置</a>
            </li>
        </ul>
    </div>
</div>*@
